<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>控制元素</title>
		<script>
		  function changeP(){
			  //var p=document.getElementsByTagName("p")[0];
			  //var p=document.getElementById("adv");
			  var p=document.querySelector("p");
			  p.align="right";
			  // p.innerHTML="<a href='http://www.bdqn.cn' target='_blank'>We change lives!</a>";//innerText
			   p.innerText="<a href='http://www.bdqn.cn' target='_blank'>We change lives!</a>";
		  }
		  function selectLikeALL(){
			  //var likes=document.getElementsByName("like");
			  var likes=document.querySelectorAll("input[name=like]");
			  
			  for(var i=0;i<likes.length;i++){
				  likes[i].checked=true;//"checked"
			  }
		  }
		</script>
	</head>
	<body>
		<p id="adv">
			教育改变生活
		</p>
		<form>
			<fieldset>
				<legend>爱好</legend>
				<input type="checkbox" name="like" value="sing" />唱歌
				<input type="checkbox" name="like" value="dance" />跳舞
				<input type="checkbox" name="like" value="game" />游戏
				<input type="checkbox" name="like" value="study" checked />学习
			</fieldset>
			
		</form>
		<input type="button" value="修改p" onclick="changeP()" />
		<input type="button" value="爱好全选"   onclick="selectLikeALL()" />
	</body>
</html>
